import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import { RouterEnums } from "@/types";
import i18n from "@/locales/i18n.ts";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    children: [
      { path: "/", redirect: "/" + RouterEnums.HOME },
      {
        path: "/" + RouterEnums.HOME,
        name: RouterEnums.HOME,
        component: () => import("@/pages/Home/index.vue"),
        meta: { keepAlive: true },
      },
      {
        path: "/" + RouterEnums.GAMEPAGE,
        name: RouterEnums.GAMEPAGE,
        component: () => import("@/pages/GamePage/index.vue"),
      },
    ],
    meta: { keepAlive: true },
  },
  {
    path: "/detail",
    component: () => import("@/pages/DetailPageLayout/index.vue"),
    name: RouterEnums.DETAIL_PAGE,
    children: [
      {
        path: "/" + RouterEnums.ACTVIP,
        name: RouterEnums.ACTVIP,
        component: () => import("@/pages/ActivityList/actVip.vue"),
        meta: { title: i18n.global.t("navigationBar.VIP") },
      },
      {
        path: "/" + RouterEnums.VIPBONUSLIST,
        name: RouterEnums.VIPBONUSLIST,
        component: () => import("@/pages/ActivityList/vipBonusList.vue"),
        meta: { title: i18n.global.t("activity.actVIP.recordList"), permission: true },
      },
      {
        path: "/" + RouterEnums.ACTSIGNIN,
        name: RouterEnums.ACTSIGNIN,
        component: () => import("@/pages/ActivityList/actSignIn.vue"),
        meta: { title: i18n.global.t("activity.signIn.mysteriousBonus") },
      },
      {
        path: "/" + RouterEnums.SYSTEMNOTIFY,
        name: RouterEnums.SYSTEMNOTIFY,
        component: () => import("@/pages/SystemNotify/index.vue"),
        meta: { title: i18n.global.t("navigationBar.message") },
      },
      {
        path: "/" + RouterEnums.WITHDRAWALS,
        name: RouterEnums.WITHDRAWALS,
        component: () => import("@/pages/Withdrawals/index.vue"),
        meta: { title: i18n.global.t("navigationBar.paymentName") },
      },
      {
        path: "/" + RouterEnums.RECHARGE,
        name: RouterEnums.RECHARGE,
        component: () => import("@/pages/Recharge/index.vue"),
        meta: { title: i18n.global.t("navigationBar.deposit") },
      },
      {
        path: "/" + RouterEnums.USERSET,
        name: RouterEnums.USERSET,
        component: () => import("@/pages/UserSet/index.vue"),
        meta: { title: i18n.global.t("navigationBar.configuration"), permission: true },
      },
      {
        path: "/" + RouterEnums.ACTIVITY_LIST,
        name: RouterEnums.ACTIVITY_LIST,
        component: () => import("@/pages/ActivityList/index.vue"),
        meta: { title: i18n.global.t("navigationBar.activityList") },
      },
      {
        path: "/" + RouterEnums.TREASUREChEST,
        name: RouterEnums.TREASUREChEST,
        component: () => import("@/pages/ActivityList/treasureChest.vue"),
        meta: { title: i18n.global.t("navigationBar.treasureChest") },
      },
      {
        path: "/" + RouterEnums.DISTRIAGENT,
        name: RouterEnums.DISTRIAGENT,
        component: () => import("@/pages/ActivityList/distriAgent.vue"),
        meta: { title: i18n.global.t("navigationBar.Agent") },
      },
      {
        path: "/" + RouterEnums.ACTRELIEF,
        name: RouterEnums.ACTRELIEF,
        component: () => import("@/pages/ActivityList/actRelief.vue"),
        meta: { title: i18n.global.t("navigationBar.relief") },
      },
      {
        path: "/" + RouterEnums.GAMELOG,
        name: RouterEnums.GAMELOG,
        component: () => import("@/pages/GameLog/index.vue"),
        meta: { title: i18n.global.t("navigationBar.gameLog") },
      },
      {
        path: "/" + RouterEnums.GAMEDETAIL,
        name: RouterEnums.GAMEDETAIL,
        component: () => import("@/pages/GameDetail/index.vue"),
        meta: { title: i18n.global.t("navigationBar.gameDetail") },
      },
      {
        path: "/" + RouterEnums.SUBORDINATELIST,
        name: RouterEnums.SUBORDINATELIST,
        component: () => import("@/pages/ActivityList/subordinateList.vue"),
        meta: { title: i18n.global.t("navigationBar.subordinateList") },
      },
      {
        path: "/" + RouterEnums.MONEYRAIN,
        name: RouterEnums.MONEYRAIN,
        component: () => import("@/pages/ActivityList/moneyRain.vue"),
        // meta: { title: i18n.global.t("invite.myInvite"), permission: true },
      },
      {
        path: "/" + RouterEnums.LEVELREWARDSPAGE,
        name: RouterEnums.LEVELREWARDSPAGE,
        component: () => import("@/pages/ActivityList/levelRewardsPage.vue"),
        meta: { title: i18n.global.t("navigationBar.Level") },
      },
      {
        path: "/" + RouterEnums.WEBSITEREBATES,
        name: RouterEnums.WEBSITEREBATES,
        component: () => import("@/pages/ActivityList/websiteRebates.vue"),
        meta: { title: i18n.global.t("navigationBar.websiteRebuttal") },
      },
      {
        path: "/" + RouterEnums.SIPERMEMBERDAY,
        name: RouterEnums.SIPERMEMBERDAY,
        component: () => import("@/pages/ActivityList/superMemberDay.vue"),
        meta: { title: i18n.global.t("navigationBar.superMemberDay") },
      },
      {
        path: "/" + RouterEnums.ADDCARDS,
        name: RouterEnums.ADDCARDS,
        component: () => import("@/pages/Withdrawals/addCards.vue"),
        meta: { title: i18n.global.t("navigationBar.BindEwallet") },
      },
    ],
  },
  {
    path: "/" + RouterEnums.LOGIN,
    name: RouterEnums.LOGIN,
    component: () => import("@/pages/Login/index.vue"),
  },
  {
    path: "/" + RouterEnums.SAFEGUARDPAGE,
    name: RouterEnums.SAFEGUARDPAGE,
    component: () => import("@/pages/safeguardPage/index.vue"),
  },
];

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: routes,
});

export default router;
